package com.orange.quickback.demo3;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

@Repository
@CacheConfig(cacheNames = "student_cache")
public class StudentCacheRepository {
    @Cacheable
    public Student getStudentById(Integer id){
        System.out.println("getStudentById");
        Student student = new Student("AA","B","CC");
        student.setId(Long.valueOf(id));
        return student;
    }
    @CachePut
    public Student updateBookById(Student student){
        student.setName("aaa");
        return student;
    }
    @CacheEvict
    public void deleteBookById(Integer id){
        System.out.println ("deleteBookById") ;
    }
}
